<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //数组元素去重处理原理：用旧数组元素去查询新数组，不存在就往新数组里添加数组元素，存在就跳过
        function unique(arr){   
            var newArr = [];
            for(var i = 0; i < arr.length; i++){
                if(newArr.indexOf(arr[i]) == -1){
                    newArr.push(arr[i]);
                }
            }
            return newArr;
        }
        var arr = [12,22,23,24,42,22,24];
        console.log(unique(arr));
    </script>
</head>
<body>
    
</body>
</html>